<script setup lang="ts">

import PageList from "@/components/page/PageList.vue";
import {ref} from "vue";
import {useRoute} from "vue-router";
import FormSlotItem from "@/components/slot/FormSlotItem.vue";

const route = useRoute();

let list_cols:{[key:string]:any} = {
  id:{name:'id', label:'ID', width:'65px', fixed:'left', type: 'hidden', order:true},
  head_img: {name:'head_img', label:'头像', width:'45px', type:'file_img'},
  nickname: {name:'nickname', label:'管理员昵称', width: '120px'},
  path: {name:'path', label:'操作路径', min_width:'120px'},
  path_alias: {name:'path_alias', label:'操作内容', min_width:'120px'},
  http_status_code: {name:'http_status_code', label:'状态码', width:'60px'},
  ip: {name:'ip', label:'IP地址', width:'130px'},
};
if (route.query['is_del']){
  list_cols['delete_time'] = {name:'delete_time', label:'删除时间', width:'165px', type:'datetime'};
}else {
  list_cols['create_time'] = {name:'create_time', label:'操作时间', width:'165px'};
}
list_cols['action'] = {name:'action', label:'操作', width:'80px', type:'_action_', fixed:'right'};

const cols = ref(list_cols)

function to_edit(row:any){
  console.log(row, 'to_edit')
}
function add(){
  console.log('add')
}

// admin_ids: {label:'管理员',name:'where[admin_id][in]',type:'list_ids',no_table:true,config:'admin/index',value:''},
// path: {label:'操作路径',name:'where[path][like]',type:'text_one',value:''},
</script>

<template>
  <PageList url="/admin/admin_log/list" title="管理员日志" :cols="cols">
    <template #form>
      <FormSlotItem name="where[admin_id][in]" label="管理员" _type_="list_ids" :_props_="{config:'admin/index', no_table:true}" />
      <FormSlotItem name="where[path][like]" label="操作路径" _type_="text_one" />
    </template>

    <template #buttons>
      <el-button type="primary"  @click="add">添加</el-button>
    </template>

    <template #_action_="{row}">
      <el-button @click="to_edit(row)" size="small">详情</el-button>
    </template>
  </PageList>
</template>

<style scoped>

</style>